package com.ocom.wxapi.controller;

import com.ocom.common.constant.SuguanmqUrl;
import com.ocom.common.request.wx.InpayCustomerRequest;
import com.ocom.common.request.wx.InpayCustomerStatusRequest;
import com.ocom.common.resp.Result;
import com.ocom.security.authentication.YoCiUser;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.wxapi.client.SuguandmqClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@PreAuthorize("hasRole('ROLE_WX')")
@RestController
public class SuguandmqController {
    @Autowired
    private SuguandmqClient suguandmqClient;

    @PostMapping(SuguanmqUrl.INPAY_CUSTOMER_STATUS_URL)
    public Result inpayCustomerStatus(@RequestBody InpayCustomerStatusRequest inpayCustomerStatusRequest){
        YoCiUser yoCiUser = SecurityUtils.getYoCiUser();
        inpayCustomerStatusRequest.setComId(yoCiUser.getComId());
        return this.suguandmqClient.inpayCustomerStatus(inpayCustomerStatusRequest);
    }

    @PostMapping(SuguanmqUrl.INPAY_CUSTOMER_URL)
    public Result inpayCustomer(@RequestBody InpayCustomerRequest inpayCustomerRequest){
        YoCiUser yoCiUser = SecurityUtils.getYoCiUser();
        inpayCustomerRequest.setComId(yoCiUser.getComId());
        inpayCustomerRequest.setSize(10);
        return this.suguandmqClient.inpayCustomer(inpayCustomerRequest);
    }


}
